<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8">
    <title>Example: Dual Axes Chart</title>
    <link rel="stylesheet" href="http://yui.yahooapis.com/3.4.0pr3/build/cssgrids/grids-min.css">
    <link rel="stylesheet" href="../assets/css/main.css">
    <link rel="stylesheet" href="../assets/vendor/prettify/prettify-min.css">
    <script src="../../build/yui/yui-min.js"></script>
</head>
<body>

<div id="doc">
    <h1>Example: Dual Axes Chart</h1>

    

    <div class="yui3-g">
        <div id="main" class="yui3-u">
            <div class="content"><style scoped>
#mychart {
    margin:10px 10px 10px 10px;
    width:90%;
    max-width: 800px;
    height:400px;
}
</style>
<div class="intro">
<p>This example shows how to create a <code>Chart</code> with multiple value axes.</p>
</div>
<div class="example">
<div id="mychart"></div>
<script type="text/javascript">
(function() {
    YUI().use('charts', function (Y) 
    { 
        var myDataValues = [ 
            {month:"January", internetSales: 110000, percentOfRevenue: 25},
            {month:"February", internetSales: 333500, percentOfRevenue: 28},
            {month:"March", internetSales: 90500, percentOfRevenue: 15},
            {month:"April", internetSales: 255550, percentOfRevenue: 21},
            {month:"May", internetSales: 445000, percentOfRevenue: 33},
            {month:"June", internetSales: 580000, percentOfRevenue: 38}
        ];
       
        //Define axes and assign keys
        var myAxes = {
            percentage: {
                type:"numeric",
                position:"right",
                keys:["percentOfRevenue"],
                labelFormat: {suffix:"%"}
            },
            sales: {
                type:"numeric",
                position:"left",
                keys:["internetSales"],
                labelFormat: {
                    prefix:"$",
                    thousandsSeparator:","
                }
            }
        };

        //Define a series collection so that we can assign nice display names
        var mySeries = [
            {type:"combo", yKey:"internetSales", yDisplayName:"Internet Sales", xDisplayName:"Month"},
            {type:"combo", yKey:"percentOfRevenue", yDisplayName:"Percent of Total Revenue", xDisplayName:"Month"}
        ];

        var mychart = new Y.Chart({
                                dataProvider:myDataValues, 
                                categoryKey:"month", 
                                axes:myAxes, 
                                seriesCollection:mySeries, 
                                render:"#mychart"
                            });
    });
})();
</script>

</div>
<h3>Creating a <code>Chart</code> with multiple axes.</h3>


<p>Multiple axes charts are useful for comparing trends in two or more data sets whose numeric range differs greatly. In this example, we'll create two <code>NumericAxis</code> through the 
<code>axes</code> attribute. By defining a separate axis for each key in our data provider, we can plot percentages and dollar sales on the same graph.</p>

<pre class="code prettyprint">YUI().use(&#x27;charts&#x27;, function (Y) 
{ 
    var myDataValues = [ 
        {month:&quot;January&quot;, internetSales: 110000, percentOfRevenue: 25},
        {month:&quot;February&quot;, internetSales: 333500, percentOfRevenue: 28},
        {month:&quot;March&quot;, internetSales: 90500, percentOfRevenue: 15},
        {month:&quot;April&quot;, internetSales: 255550, percentOfRevenue: 21},
        {month:&quot;May&quot;, internetSales: 445000, percentOfRevenue: 33},
        {month:&quot;June&quot;, internetSales: 580000, percentOfRevenue: 38}
    ];
   
    &#x2F;&#x2F;Define axes and assign keys
    var myAxes = {
        percentage: {
            type:&quot;numeric&quot;,
            position:&quot;right&quot;,
            keys:[&quot;percentOfRevenue&quot;],
            labelFormat: {suffix:&quot;%&quot;}
        },
        sales: {
            type:&quot;numeric&quot;,
            position:&quot;left&quot;,
            keys:[&quot;internetSales&quot;],
            labelFormat: {
                prefix:&quot;$&quot;,
                thousandsSeparator:&quot;,&quot;
            }
        }
    };

    &#x2F;&#x2F;Define a series collection so that we can assign nice display names
    var mySeries = [
        {type:&quot;combo&quot;, yKey:&quot;internetSales&quot;, yDisplayName:&quot;Internet Sales&quot;, xDisplayName:&quot;Month&quot;},
        {type:&quot;combo&quot;, yKey:&quot;percentOfRevenue&quot;, yDisplayName:&quot;Percent of Total Revenue&quot;, xDisplayName:&quot;Month&quot;}
    ];

    var mychart = new Y.Chart({
                            dataProvider:myDataValues, 
                            categoryKey:&quot;month&quot;, 
                            axes:myAxes, 
                            seriesCollection:mySeries, 
                            render:&quot;#mychart&quot;
                        });
});</pre>

</div>
        </div>

        <div id="sidebar" class="yui3-u">
            

            
                <div class="sidebox">
                    <div class="hd">
                        <h2 class="no-toc">Examples</h2>
                    </div>

                    <div class="bd">
                        <ul class="examples">
                            
                                
                                    <li data-description="Shows how to use Charts to create a basic chart.">
                                        <a href="charts-simple.html">Basic Charts Implementation</a>
                                    </li>
                                
                            
                                
                                    <li data-description="Shows how to create a chart with multiple series.">
                                        <a href="charts-multiseries.html">Chart with Multiple Series</a>
                                    </li>
                                
                            
                                
                                    <li data-description="Shows how to create a column chart with multiple series.">
                                        <a href="charts-column.html">Specify Chart Type</a>
                                    </li>
                                
                            
                                
                                    <li data-description="Shows how to create a column chart with a stacked numeric axis.">
                                        <a href="charts-stackedcolumn.html">Create Stacked Chart</a>
                                    </li>
                                
                            
                                
                                    <li data-description="Shows how to create a chart with a time axis.">
                                        <a href="charts-timeaxis.html">Create a Chart with a Time Axis</a>
                                    </li>
                                
                            
                                
                                    <li data-description="Shows how to add gridlines to a chart.">
                                        <a href="charts-gridlines.html">Add Gridlines to a Chart</a>
                                    </li>
                                
                            
                                
                                    <li data-description="Shows how to create a chart with planar based events.">
                                        <a href="charts-stackedarea.html">Create a Stacked Area Chart with Planar Based Events</a>
                                    </li>
                                
                            
                                
                                    <li data-description="Shows how to use a chart&#x27;s styles attribute to customize a chart.">
                                        <a href="charts-globalstyles.html">Customize a Chart</a>
                                    </li>
                                
                            
                                
                                    <li data-description="Shows how to customize the default tooltip of a chart.">
                                        <a href="charts-customizedtooltip.html">Customize a Chart&#x27;s Tooltip</a>
                                    </li>
                                
                            
                                
                                    <li data-description="Shows how to explicitly define the axes and series for a chart.">
                                        <a href="charts-objectstyles.html">Define a Chart&#x27;s Axes and Series</a>
                                    </li>
                                
                            
                                
                                    <li data-description="Shows how to use charts to create a pie chart.">
                                        <a href="charts-pie.html">Pie Chart</a>
                                    </li>
                                
                            
                                
                                    <li data-description="Shows how to create a chart with multiple value axes.">
                                        <a href="charts-dualaxes.html">Dual Axes Chart</a>
                                    </li>
                                
                            
                                
                                    <li data-description="Shows how to access a chart instance&#x27;s value axis after the chart has rendered.">
                                        <a href="charts-axisupdate.html">Update Chart Axis</a>
                                    </li>
                                
                            
                                
                                    <li data-description="Shows how to access a chart instance&#x27;s seriesCollection after the chart has rendered.">
                                        <a href="charts-seriesupdate.html">Update Chart Series</a>
                                    </li>
                                
                            
                        </ul>
                    </div>
                </div>
            

            
        </div>
    </div>
</div>

<script src="../assets/vendor/prettify/prettify-min.js"></script>
<script>prettyPrint();</script>

</body>
</html>
